<link rel="stylesheet" href="/assets/home/city/css/city-picker.css">
<link rel="stylesheet" href="/assets/home/css/profile.css">

<script src="/assets/home/city/js/city-picker.data.min.js"></script>
<script src="/assets/home/city/js/city-picker.min.js"></script>

<!-- 引入axios 请求插件 -->
<script src="/assets/home/plugins/axios/axios.min.js"></script>
<script src="/assets/home/plugins/axios/request.js"></script>

<!-- 头部 -->
<div class="top_div">
    <img src="/assets/home/images/bac.jpg" class="top_img">
    <div class="userInfo">
        <!-- {if !empty($login['avatar'])} -->
        <img id="ava" class="uPic" src="{$login.avatar_text}" /><br />
        <!-- {else /} -->
        <!-- <img id="ava" class="uPic" src="/assets/home/images/avatar.jpg" /><br /> -->
        <!-- {/if} -->
        <span class="uBalance" style="">{$login.nickname_text}</span>
    </div>
</div>

<div class="form">
    <!-- 表单提交，有文件上传要设置enctype -->
    <form method="post" enctype="multipart/form-data" action="{:url('home/business/check')}">
        <div class="item">
            <div class="title">邮箱：</div>
            <input type="text" name="email" placeholder="请输入邮箱" value="{$login.email}" readonly>
            <!-- <input type="button" value="发送验证码"> -->
            <button id="send">发送验证码</button>
        </div>
        <div class="item">
            <div class="title">验证码：</div>
            <input type="text" name="code" placeholder="请输入验证码" required>
        </div>
        <input type="submit" value="提交">
        <!-- <input type="reset" value="重置"> -->
    </form>
</div>
<style>
    #send {
        font-size: 10px;
        padding: 1px 8px;
        background: green;
        color: white;
        border-radius: 10px;
    }
</style>
<script>
    var sec=60;
    var T
    $("#send").click(async function(){
        //发送请求
        var result=await POST({
            url:'/home/business/email',
            params: {}
        })
        //轻提醒
        mui.toast(result.msg, {duration: 3000})
        
        //倒计时
        $(this).html(sec);
        $(this).attr('disabled', true)
        autoplay();
        T = setInterval(autoplay, 500)
    })
    function autoplay()
    {
        var num = $("#send").html()
            num = parseInt(num)

        if(num <= 0)
        {
            //停止定时器
            clearInterval(T)
            $("#send").removeAttr('disabled')
            $("#send").html('重新发送验证码')
        }else
        {
            $('#send').html(num-1)
        }
    }
</script>